<?php
class admin_listController extends adminController{

    //首页
    public function index() {
        $cid=intval($_GET['cid']);
        $this->alert_str($cid,'int');
        $this->info=model('filter_category')->info($cid);
        $this->list=model('filter_list')->filter_list($cid);
        $this->show();  
    }

    public function data_check($data)
    {
        if(model('filter_list')->filter_info($data['cid'],$data['urlname'],$data['fid'])){
            $this->msg('属性英文不能重复！',0);
        }
    }

    //添加
    public function add() {
        $cid=intval($_GET['cid']);
        $this->alert_str($cid,'int');
        $this->class_info=model('filter_category')->info($cid);
        $this->action_name='添加';
        $this->action='add';
        $this->show('admin_list/info'); 
    }

    public function add_save() {
        //录入模型处理
        $this->data_check($_POST); 
        model('filter_list')->add($_POST);
        $this->msg('属性添加成功！',1);
    }

    //修改
    public function edit() {
        $fid=$_GET['fid'];
        $this->alert_str($fid,'int');
        $this->info=model('filter_list')->info($fid);
        $this->class_info=model('filter_category')->info($this->info['cid']);
        $this->action_name='编辑';
        $this->action='edit';
        $this->show('admin_list/info'); 
    }

    public function edit_save() {
        $fid=$_POST['fid'];
        $this->alert_str($fid,'int',true);
        //录入模型处理
        $this->data_check($_POST); 
        model('filter_list')->edit($_POST);
        $this->msg('属性修改成功! ',1);
    }

    //删除
    public function del() {
        $fid=intval($_POST['fid']);
        $this->alert_str($fid,'int',true); 
        //录入模型处理
        model('filter_list')->del($fid);
        $this->msg('属性删除成功！',1);
    }

    //获取过滤信息
    public function get_filter() {
        $cid=intval($_POST['cid']);
        $aid=intval($_POST['aid']);
        if(empty($cid)){
            return;
        }
        echo model('filter_list')->get_filter($cid,$aid);
    }





}